var cloud_2 = []
Object.keys(data).forEach(state => {
    cloud_2.push({
        "name": state,
        "value": data[state]['2020/05/19']['cumsum_confirmed']
    })

})

// 取前十个最小的
var top_mas_10 = cloud_2.sort(function(a, b) {
    return b.value - a.value
}).slice(0, 10)

// for (var idx = 0; idx < 10; idx++) {
//     min_10[idx] = min_10[idx] / min_10[-1]
// }

console.log('top_mas_10', top_mas_10)



var cloud_2_data = {
    value: top_mas_10,
    image: ''

}
var maskImage = new Image();
maskImage.src = cloud_2_data.image


var word_cloud_2_option = {
    title: {
        text: 'Top 10 States with Most Cases',
        left: '10%'
    },
    // backgroundColor: '#fff',
    tooltip: {
        show: true
    },
    series: [{
        type: 'wordCloud',
        gridSize: 1,
        sizeRange: [12, 55],
        rotationRange: [-45, 0, 45, 90],
        maskImage: maskImage,
        textStyle: {
            normal: {
                color: function() {
                    return 'rgb(' +
                        Math.round(Math.random() * 255) +
                        ', ' + Math.round(Math.random() * 255) +
                        ', ' + Math.round(Math.random() * 255) + ')'
                }
            }
        },
        left: '15%',
        top: 'center',
        width: '100%',
        height: '100%',
        right: null,
        bottom: null,
        data: cloud_2_data.value
    }]


}


$(function() {

    var word_cloud_2 = echarts.init(document.getElementById('word_cloud_2'))
    console.log('set cloud2')
    word_cloud_2.setOption(word_cloud_2_option)
})